<?php 
/**
 * 登录控制器
 */
class LoginController extends Controller{
    /**
     * 
     */
    public function index(){
       if(IS_POST){
    		$model = K('User');
		   if(!$userInfo = $model->vLogin()){
		   		$this->error($model->error);
		   }
		   $_SESSION['uname'] = $userInfo['username'];
		   $_SESSION['uid'] = $userInfo['uid'];
		   //如果选择自动登录则设置cookie，没有选择则不设置
			if(isset($_POST['auto'])){
				setcookie(session_name(),session_id(),time() + 3600 *24 *7, '/');
			}else{
				setcookie(session_name(),session_id(),0,'/');
			}
		   $this->success('登陆成功',U('Index/index'));
       }
	   $this->display();
    }
	

	
 }
 



 ?>